
package org.springblade.common.enums.rate;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 角色ID
 1123598816738675201	000000	0	超级管理员
 1363484909269372929	000000	0	开发者
 1378329859197620226	000000	0	财务
 1382693986453041153	000000	0	人事
 1382694079189102593	000000	0	仓库
 1382694132251242498	000000	0	采购
 1382694179189698562	000000	0	销售
 1382694241760325633	000000	0	工程
 * @author samwuu
 */
@Getter
@AllArgsConstructor
public enum UserRoleEnum {

	ADMIN("ADMIN","超级管理员", 1123598816738675201L),
	DEV("DEV","开发者", 1363484909269372929L),
	FINANCE("FINANCE","财务", 1378329859197620226L),
	OA("OA","人事", 1382693986453041153L),
	INVENTORY("INVENTORY","仓库", 1382694079189102593L),
	PURCHASE("PURCHASE","采购", 1382694132251242498L),
	SALE("SALE","销售", 1382694179189698562L),
	PRODUCTION("PRODUCTION","工程", 1382694241760325633L),
	;

	final String keyword;
	final String desc;
	final Long key;

	public static UserRoleEnum getEnum(Long key) {
		if (key == null) {
			return UserRoleEnum.ADMIN;
		} else {
			for (UserRoleEnum s : UserRoleEnum.values()) {
				if (s.getKey().equals(key)) {
					return s;
				}
			}
			return UserRoleEnum.ADMIN;
		}
	}

	public static UserRoleEnum getEnum(String keyword) {
		if (keyword == null) {
			return null;
		} else {
			for (UserRoleEnum s : UserRoleEnum.values()) {
				if (s.getKeyword().equals(keyword)) {
					return s;
				}
			}
			return null;
		}
	}

}
